home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / CVersCaption 1.3.1 / CVersCaptionTest PPC / PP Basic Starter.cp < prev    next >
Encoding:
Text File  |  1997-06-24  |  3.8 KB  |  149 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    PP Basic Starter.cp         ©1994-1996 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    This file contains the starter code for a basic PowerPlant application
  6.  
  7. #include "PP Basic Starter.h"
  8.  
  9. #include <LGrowZone.h>
  10. #include <LWindow.h>
  11. #include <LCaption.h>
  12. #include <PP_Messages.h>
  13. #include <PP_Resources.h>
  14. #include <UDrawingState.h>
  15. #include <UMemoryMgr.h>
  16. #include <URegistrar.h>
  17.  
  18. #include "CVersCaption.h"
  19.  
  20. // put declarations for resource ids (ResIDTs) here
  21.  
  22. const ResIDT    window_Sample        = 1;    // EXAMPLE
  23.  
  24.  
  25. // ===========================================================================
  26. //        • Main Program
  27. // ===========================================================================
  28.  
  29. void main(void)
  30. {
  31.                                     // Set Debugging options
  32.     SetDebugThrow_(debugAction_Alert);
  33.     SetDebugSignal_(debugAction_Alert);
  34.  
  35.     InitializeHeap(3);                // Initialize Memory Manager
  36.                                     // Parameter is number of Master Pointer
  37.                                     //   blocks to allocate
  38.     
  39.                                     // Initialize standard Toolbox managers
  40.     UQDGlobals::InitializeToolbox(&qd);
  41.     
  42.     new LGrowZone(20000);            // Install a GrowZone function to catch
  43.                                     //    low memory situations.
  44.  
  45.     CPPStarterApp    theApp;            // replace this with your App type
  46.     theApp.Run();
  47. }
  48.  
  49.  
  50. // ---------------------------------------------------------------------------
  51. //        • CPPStarterApp             // replace this with your App type
  52. // ---------------------------------------------------------------------------
  53. //    Constructor
  54.  
  55. CPPStarterApp::CPPStarterApp()
  56. {
  57.     RegisterClass_(CVersCaption);
  58.     RegisterClass_(LWindow);
  59.     RegisterClass_(LCaption);
  60. }
  61.  
  62.  
  63. // ---------------------------------------------------------------------------
  64. //        • ~CPPStarterApp            // replace this with your App type
  65. // ---------------------------------------------------------------------------
  66. //    Destructor
  67. //
  68.  
  69. CPPStarterApp::~CPPStarterApp()
  70. {
  71. }
  72.  
  73. // ---------------------------------------------------------------------------
  74. //        • StartUp
  75. // ---------------------------------------------------------------------------
  76. //    This function lets you do something when the application starts up
  77. //    without a document. For example, you could issue your own new command.
  78.  
  79. void
  80. CPPStarterApp::StartUp()
  81. {
  82.     ObeyCommand(cmd_New, nil);        // EXAMPLE, create a new window
  83. }
  84.  
  85. // ---------------------------------------------------------------------------
  86. //        • ObeyCommand
  87. // ---------------------------------------------------------------------------
  88. //    Respond to commands
  89.  
  90. Boolean
  91. CPPStarterApp::ObeyCommand(
  92.     CommandT    inCommand,
  93.     void        *ioParam)
  94. {
  95.     Boolean        cmdHandled = true;
  96.  
  97.     switch (inCommand) {
  98.     
  99.         // Deal with command messages (defined in PP_Messages.h).
  100.         // Any that you don't handle will be passed to LApplication
  101.              
  102.         case cmd_New:
  103.                                     // EXAMPLE, create a new window
  104.             LWindow        *theWindow;
  105.             theWindow = LWindow::CreateWindow(window_Sample, this);    
  106.             theWindow->Show();
  107.  
  108.             break;
  109.  
  110.  
  111.         default:
  112.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  113.             break;
  114.     }
  115.     
  116.     return cmdHandled;
  117. }
  118.  
  119. // ---------------------------------------------------------------------------
  120. //        • FindCommandStatus
  121. // ---------------------------------------------------------------------------
  122. //    This function enables menu commands.
  123. //
  124.  
  125. void
  126. CPPStarterApp::FindCommandStatus(
  127.     CommandT    inCommand,
  128.     Boolean        &outEnabled,
  129.     Boolean        &outUsesMark,
  130.     Char16        &outMark,
  131.     Str255        outName)
  132. {
  133.  
  134.     switch (inCommand) {
  135.     
  136.         // Return menu item status according to command messages.
  137.         // Any that you don't handle will be passed to LApplication
  138.  
  139.         case cmd_New:                    // EXAMPLE
  140.             outEnabled = true;            // enable the New command
  141.             break;
  142.  
  143.         default:
  144.             LApplication::FindCommandStatus(inCommand, outEnabled,
  145.                                                 outUsesMark, outMark, outName);
  146.             break;
  147.     }
  148. }
  149.